package service;

import java.math.BigInteger;
import java.util.List;

import beans.Agent;
import beans.Express;

import dao.ExpressDao;
import dao.QueryDAO;


public class ExpressService implements ExpressServiceInterface {

    private List<Express> expresses = null;

    QueryDAO queryDAO = new QueryDAO();
    ExpressDao expressDao = new ExpressDao();

    String sql = null;
    String hql = null;

    public List<Express> getExpressPage(Agent agent, int rows, int page) {
        return expressDao.getExpressPage(agent, rows, page);
    }

    public int getExpressNumber(Agent agent) {
        sql = "select count(e.express_id) from express e where e.express_agent_id = ?";
        return ((BigInteger) queryDAO.queryUniques(sql, agent.getId())).intValue();
    }
    
    public void deleteExpress(String ids) {//delete 操作不能用表别名
        sql = "delete from express where express_id in ("+ids+")";
        queryDAO.queryExcute(sql);
    }

}